<html lang="en">
<head>
<meta charset="UTF-8">
<title>一片綠葉后台管理系统登录</title>
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link rel="shortcut icon" href="./favicon.ico" type="image/x-icon" />
<link rel="stylesheet" href="static/css/font.css">
<link rel="stylesheet" href="../../../DogHome/layui/css/layui.css" media="all" />
<link rel="stylesheet" href="static/css/weadmin.css"> 


</head>
<body class="login-bg">

	<div class="login">
		<div class="message">一片綠葉后台管理系统登录</div>
		<div id="darkbannerwrap"></div>

		<form method="post" class="layui-form" id="login">
			<input name="name" placeholder="用户名" type="text" id="name"
				lay-verify="required" class="layui-input">
			<hr class="hr15">
			<input name="pwd" lay-verify="required|pass" id="pwd"
				placeholder="密码" type="password" class="layui-input">
			<hr class="hr15">
			<input class="loginin layui-btn" value="登录" lay-submit
				lay-filter="login" style="width: 100%;">
			<hr class="hr20">

		</form>
	</div>
<script type="text/javascript" src="layui/layui.js"></script>
	<script type="text/javascript">
		layui.use(['form', 'layer'], function(){
			 var form = layui.form();
			var layer = layui.layer;
			var $ = layui.jquery;
			$("#pwd").blur(function(e) {
				if (/^[\S]{6,12}$/.test($("#pwd").val())) {
					layer.msg("密码格式正确", {
						icon : 6
					});
				} else {
					layer.msg("密码必须6到12位", {
						icon : 5
					});
				}
			})
			$("#name").blur(
					function(e) {
						if ($("#name").val().length <= 6
								&& $("#name").val().length >= 2) {
							layer.msg("用户名格式正确", {
								icon : 6
							});
						} else {
							layer.msg("用户名为2~6位", {
								icon : 5
							});
						}
					})
			form.on('submit(login)', function(data){
				$.post('http://localhost:8080/DogHome/login?md=toLogin', 
						$("#login").serialize(), function(res) {
					if (res.success) {
						layer.alert(res.message);
						//存放用户名
						sessionStorage.setItem("uname",$("#name").val());
						location.href = 'index.html';
					} else {
						layer.alert(res.message,{icon:2});
					}
				}, "json");
				
			})
		})
	</script>

</body>
</html>